package com.ruoyi.web.controller.ufox;


import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ufox.domain.BisDevice;
import com.ruoyi.ufox.domain.BisDeviceDataDay;
import com.ruoyi.ufox.service.IBisDeviceDataDayService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 数据日统计Controller
 * 
 * @author ufoxs
 * @date 2022-08-17
 */
@RestController
@RequestMapping("/bussiness/daydata")
public class BisDeviceDataDayController extends BaseController
{
    @Autowired
    private IBisDeviceDataDayService bisDeviceDataDayService;

    /**
     * 查询数据日统计列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:daydata:list')")
    @RequestMapping("/list")
    public TableDataInfo list(BisDeviceDataDay bisDeviceDataDay)
    {
        startPage();
        List<BisDeviceDataDay> list = bisDeviceDataDayService.selectBisDeviceDataDayList(bisDeviceDataDay);
        return getDataTable(list);
    }

    /**
     * 导出数据日统计列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:daydata:export')")
    @Log(title = "数据日统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisDeviceDataDay bisDeviceDataDay)
    {
        List<BisDeviceDataDay> list = bisDeviceDataDayService.selectBisDeviceDataDayList(bisDeviceDataDay);
        ExcelUtil<BisDeviceDataDay> util = new ExcelUtil<BisDeviceDataDay>(BisDeviceDataDay.class);
        util.exportExcel(response, list, "数据日统计数据");
    }

    /**
     * 获取数据日统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:daydata:query')")
    @RequestMapping(value = "/{recordId}")
    public AjaxResult getInfo(String deviceId, Date date)
    {
        Map<String,Object> map=this.getInfo(deviceId,date);

        return AjaxResult.success(map);
    }

    /**
     * 新增数据日统计
     */
    @PreAuthorize("@ss.hasPermi('bussiness:daydata:add')")
    @Log(title = "数据日统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BisDeviceDataDay bisDeviceDataDay)
    {
        return toAjax(bisDeviceDataDayService.insertBisDeviceDataDay(bisDeviceDataDay));
    }

   @GetMapping("/ss")
   public AjaxResult getTimg(String deviceCode,String date) {
       List<BisDeviceDataDay> list=bisDeviceDataDayService.getTimg(deviceCode, date);
       return new AjaxResult(200,"",list);
    }
}
